package com.htandroid.htandroid.aty;

import android.content.res.Resources;
import android.os.Bundle;
import android.widget.LinearLayout;

import com.ab.activity.AbActivity;
import com.ab.view.titlebar.AbTitleBar;
import com.gyf.barlibrary.ImmersionBar;
import com.htandroid.htandroid.R;

/**
 * Created by caih on 2018/8/17.
 * 实现 沉浸是状态栏 activity
 */
public abstract class MyBaseActivity extends AbActivity {

    public AbTitleBar titleBar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        titleBar = getTitleBar();
        titleBar.setTitleBarBackground(R.color.app_blue);
        titleBar.setPadding(dp2Px(15), dp2Px(15), dp2Px(15), 0);
        titleBar.getLogoView().setLayoutParams(new LinearLayout.LayoutParams(dp2Px(20), dp2Px(20)));
        titleBar.setTitlePadding(0, 0, dp2Px(20), 0);
        ImmersionBar.with(this).statusBarDarkFont(true).init();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ImmersionBar.with(this).destroy();
    }

    public int dp2Px(int dp) {
        return Math.round(dp * Resources.getSystem().getDisplayMetrics().density);
    }
}
